<template>
	<view class="container" :style="{'minHeight':!heights?'100vh':`calc(100vh - ${heights}rpx)`}">
		<view class="content">
			<!-- <view class="list" v-for="(item,index) in invoiceList" :key="index" @click="selectClick(item)">
				<view class="infos">
					<view class="user_info">{{item.company_name}}
					</view>
					<view class="address">纳税人识别号：{{item.identification}}</view>
				</view>
				<view class="select_box">选择</view>
			</view> -->
			<view class="list" v-for="(item,index) in invoiceList" :key="index" @click="selectClick(item)">
				<view class="infos">
					<view class="user_info">
						<view v-if="item.is_default == 1">默认</view>{{item.company_name}}
					</view>
					<view class="address">纳税人识别号：{{item.identification}}</view>
				</view>
				<view class="right_box"
					@click.stop="$gourl('/otherPage/invoice/editIdvoice?info='+JSON.stringify(item))">
					<u-icon name="edit-pen" color="#333" size="40"></u-icon>
				</view>
			</view>
		</view>
		<view class="add_btn" @click="$gourl('/otherPage/invoice/addInvoice')">
			<!-- <u-icon name="plus-circle" color="#EA3D37" size="40"></u-icon> -->
			<text style="margin-left: 20rpx;">新增抬头</text>
		</view>
	</view>
</template>

<script>
	export default {
		props: ['heights'],
		data() {
			return {
				invoiceList: [],
				selectId: null,
				page: 1,
				pageSize: 10,
				total: 1,
				count: 1,
			}
		},
		onShow() {
			if (uni.getStorageSync('selectAddressId')) {
				this.selectId = uni.getStorageSync('selectAddressId')
			}
			this.getData()
		},
		methods: {
			async getData() {
				this.invoiceList = []
				await this.$allApi.getInvoiceTitleList().then(res => {
					this.invoiceList = res.data
				})
			},
			selectClick(item) {
				getApp().selectInvoice = JSON.stringify(item)
				this.$forceUpdate()
				this.$backTo(1)
			}
		}
	}
</script>

<style scoped lang="scss">
	.no {
		width: 40rpx;
		height: 40rpx;
		border-radius: 50%;
		border: 1px solid #ccc;
	}

	.container {
		padding: 20rpx 20rpx 120rpx 20rpx;
		padding-bottom: 120rpx;
		background: #f8f8f8;
	}

	.list {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 30rpx;
		background: #fff;
		margin-bottom: 20rpx;
		line-height: 2;

		.right_box {
			width: 100rpx;
			height: 40rpx;
			display: flex;
			align-items: center;
			justify-content: flex-end;
		}

		.select_box {
			width: 100rpx;
			height: 40rpx;
			border-radius: 8rpx;
			background: #eaf4eb;
			border: 2rpx solid #EA3D37;
			display: flex;
			align-items: center;
			justify-content: center;
			color: #EA3D37;

		}

		.infos {
			flex: 1;

			.user_info {
				font-size: 30rpx;
				font-weight: 400;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				view {
					width: 74rpx;
					height: 30rpx;
					border-radius: 30rpx;
					margin-left: 20rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					font-size: 20rpx;
					color: #e2b771;
					background: linear-gradient(to right, #585858, #333);
					;
				}
			}

			.address {
				font-size: 24rpx;
				color: #999;
			}
		}
	}

	.add_btn {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100vw;
		height: 70rpx;
		border-radius: 35rpx;
		background: #EA3D37;
		color: #fff;
		bottom: calc(20rpx + constant(safe-area-inset-bottom));
		bottom: calc(20rpx + env(safe-area-inset-bottom));
		display: flex;
		align-items: center;
		justify-content: center;
		border-top: 1px solid #eee;
	}
</style>